{include file="public/layout" /}
<style>
    .explanation{
        padding: 15px 0 13px 12px;
    }
    .ey-btn{
        color: red;
    }
   
    .plug-item-c {
        position: relative; cursor: no-drop;
        display: inline-block;
    }


    .overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色 */
        opacity: 0;
        transition: opacity 0.3s;
        display: flex; /* 使用 flexbox 居中内容 */
        justify-content: center; /* 水平居中 */
        align-items: center; /* 垂直居中 */
    }

    .overlay-text {
        color: white; /* 白色文字 */
        font-size: 16px; /* 根据需要调整字体大小 */
    }

    .plug-item-c:hover .overlay {
        opacity: 1; /* 鼠标悬停时显示蒙层 */
    }
</style>
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page min-hg-c-10">
    <div id="" class="explanation f-16 mb15">
       <li>当前系统为体验版，部分功能不可用，如需使用更多功能请前往 <a class="ey-btn" href="https://www.45cshop.com/#buy" target="_blank">45°商城官网</a> 购买授权</li>
    </div>
    <div class="flexigrid">
        <div class="plug-weapp">
            <div class="son-tit">
                <div class="">
                    扩展应用
                    <!-- <a href="{:url('Weapp/plugin')}" class="tab {eq name="$Request.action" value="plugin"}current{/eq}" style="margin-left: 20px;"><span>云插件库</span></a> -->
                </div>
            </div>
            <div class="plug-weapp-list">
                <!-- {empty name="list"}
                <div class="bDiv" style="height: auto;">
                    <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                        <table style="width: 100%">
                            <tbody>
                                <tr>
                                    <td class="no-data" align="center" axis="col0" colspan="50">
                                        <div class="no_row">
                                            <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="iDiv" style="display: none;"></div>
                </div>
                {else /} -->
                    <div class="plug-weapp-item-content">
                        <a class="plug-item-top plug-item-c" >
                            <div class="overlay">
                                <div class="overlay-text">体验版不支持此应用</div> <!-- 蒙层中的提示文字 -->
                            </div>
                            <div class="plug-icon"><i class="iconfont e-xiaoxitongzhi"></i></div>
                            <div class="plug-text">
                                <div class="plug-text-title"><span class="title-l">消息通知</span></div>
                                <div class="plug-text-des">消息推送设置</div>
                            </div>
                        </a>
                    </div>
                    <div class="plug-weapp-item-content" >
                        <a class="plug-item-top " href="{:url('Tools/index')}">
                            <div class="plug-icon"><i class="iconfont e-beifenhuanyuan"></i></div>
                            <div class="plug-text">
                                <div class="plug-text-title"><span class="title-l">备份还原</span></div>
                                <div class="plug-text-des">网站数据备份与还原</div>
                            </div>
                        </a>
                    </div>
                    <div class="plug-weapp-item-content" >
                        <a class="plug-item-top"  href="{:url('Index/theme_index')}">
                            <div class="plug-icon"><i class="iconfont e-zhutifengge"></i></div>
                            <div class="plug-text">
                                <div class="plug-text-title"><span class="title-l">主题风格</span></div>
                                <div class="plug-text-des">网站后台logo,ico,主题风格切换</div>
                            </div>
                        </a>
                    </div>
                    {foreach name="list" item="vo" key="k" }
                        {if condition="$php_servicemeal > 1 || !in_array($vo['code'], config('global.authori_gj_app'))"}
                        <div class="plug-weapp-item-content">
                            {if condition="empty($vo['config']['management']['href'])"}
                            <a class="plug-item-top plug-item-c">
                                <div class="overlay">
                                    <div class="overlay-text">体验版不支持此应用</div> <!-- 蒙层中的提示文字 -->
                                </div>
                            {else /}
                            <a class="plug-item-top plug-item-c" target="{$vo['config']['management']['target']|default='_self'}">
                                <div class="overlay">
                                    <div class="overlay-text">体验版不支持此应用</div> <!-- 蒙层中的提示文字 -->
                                </div>
                            {/if}
                            <!-- <a class="plug-item-top" href="javascript:void(0);" onclick="install(this);" data-id="{$vo['id']}"> -->
                                <div class="plug-img"><img src="{$vo.config.litpic|get_default_pic=###}?v={$vo.config.version}"></div>
                                <div class="plug-text">
                                    <div class="plug-text-title"><span class="title-l">{$vo.name}</span></div>
                                    <div class="plug-text-des">{$vo.config.description|default='暂无描述~'}</div>
                                </div>
                            </a>
                        </div>
                        {/if}
                    {/foreach}
                <!-- {/empty} -->
            </div>
        </div>
    </div>
</div>
<form name="form2" id="form2" method="post" action="">
    <input type="hidden" name="id" value="" />
    <input type="hidden" name="code" value=""/>
    <input type="hidden" name="min_version" value=""/>
    <input type="hidden" name="thorough" value="1" />
</form>
<script>
    $(document).ready(function(){

        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    function weapp_upgrade(obj)
    {
        var name = $(obj).attr('data-name');
        var status = $(obj).attr('data-status');
        if (0 == status) {
            layer.alert('请先安装该插件！', {
                title:false,//name,
                icon: 0
            });
            return false;
        }

        var code = $(obj).attr('data-code');
        var v = $("#"+code+"_upgrade").val();    
        var intro = $("#"+code+"_intro").val();   
        intro += '<style type="text/css">.layui-layer-content{height:270px!important;text-align:left!important;}</style>';
        var notice = $("#"+code+"_notice").val(); 
        v = notice + intro + '<br/>' + v;
        //询问框
        layer.confirm(v, {
            shade: layer_shade,
            area: ['580px','400px'],
            move: false,
            title: '新版本更新',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['升级','取消'], //按钮
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function(){
            layer.closeAll();
            setTimeout(function(){
                upgrade(code); // 请求后台
            },200);
            
        }, function(index){  
            layer.close(index);
        });    
    }

    function upgrade(code){
        layer_loading('升级中');
        $.ajax({
            type : "GET",
            url  : "{:url('Weapp/OneKeyUpgrade')}",
            timeout : 360000, //超时时间设置，单位毫秒 设置了 1小时
            data : {code:code, _ajax:1},
            error: function(request) {
                layer.closeAll();
                layer.alert("升级失败！", {icon: 5, closeBtn: false, title:false}, function(){
                    window.location.reload();
                });
            },
            success: function(res) {
                if(1 == res.code){
                    $.ajax({
                        type : 'GET',
                        url : eyou_basefile+"?m=admin&c=Weapp&a=execute&sm="+code+"&sc="+code+"&sa=afterUpgrade",
                        timeout : 360000, //超时时间设置，单位毫秒 设置了 1小时
                        data : {_ajax:1},
                        dataType : 'json',
                        success : function(res){
                            layer.closeAll();
                            layer.msg('已升级最新版本!', {time:1000}, function(){
                                window.location.reload();
                            });
                        },
                        error: function(e) {
                            layer.closeAll();
                            layer.msg('已升级最新版本!', {time:1000}, function(){
                                window.location.reload();
                            });
                        }
                    })
                }
                else{
                    layer.closeAll();
                    layer.alert(res.msg, {icon: 5, closeBtn: false, title:false}, function(){
                        window.location.reload();
                    });
                }
            }
        });                 
    }

    function install(obj)
    {
        var id = $(obj).attr('data-id');
        var form2 = $('#form2');
        form2.find('input[name=id]').val(id);
        var url = "{:url('Weapp/install')}";
        form2.attr('action', url);
        layer_loading('正在处理');
        form2.submit();
    }

    function uninstall(obj)
    {
        //询问框
        var confirm = layer.confirm('数据将不可恢复，是否卸载？', {
                shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                btn: ['确定', '取消'] ,//按钮
                success: function () {
                      $(".layui-layer-content").css('text-align', 'left');
                  }
            }, function(){
                layer.close(confirm);
                uninstall_true(obj);
            }, function(){
                layer.close(confirm);
            }
        );
        
        return false;
    }

    function uninstall_true(obj)
    {
        var id = $(obj).attr('data-id');

        layer_loading('正在处理');
        // 确定
        $.ajax({
            type : 'post',
            url : "{:url('Weapp/uninstall')}",
            data : {id:id, thorough:0, _ajax:1},
            dataType : 'json',
            success : function(res){
                layer.closeAll();
                if(res.code == 1){
                    layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                        var menu_id = $(obj).attr('data-menu_id');
                        $(".Weapp_execute_" + menu_id, window.parent.document).remove();
                        window.location.reload();
                    });
                }else{
                    layer.alert(res.msg, {icon: 5, title:false});
                }
            },
            error: function(e) {
                layer.closeAll();
                // 处理插件行为app_end影响到的卸载问题
                if (e.responseText.indexOf("\\behavior\\admin\\") >= 0 && e.responseText.indexOf("not found") >= 0) {
                    layer.msg('卸载成功', {icon: 1, time: 1000}, function(){
                        window.location.reload();
                    });
                } else {
                    layer.alert(e.responseText, {icon: 5, title:false});
                }
            }
        });
    }

    function delfun(obj){
        var name = $(obj).attr('data-name');
        layer.confirm('确认删除？', {
            area: ['480px', '190px'],
            shade: layer_shade,
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定','取消'] ,//按钮
            success: function () {
                  $(".layui-layer-content").css('text-align', 'left');
              }
        }, function(){
            layer_loading('正在处理');
            // 确定
            $.ajax({
                type : 'post',
                url : $(obj).attr('data-url'),
                data : {del_id:$(obj).attr('data-id'), _ajax:1},
                dataType : 'json',
                success : function(res){
                    layer.closeAll();
                    if(res.code == 1){
                        layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                            var menu_id = $(obj).attr('data-menu_id');
                            $(".Weapp_execute_" + menu_id, window.parent.document).remove();
                            window.location.reload();
                        });
                    }else{
                        layer.alert(res.msg, {icon: 5, title:false});  //alert(res);
                    }
                }
            })
        }, function(index){
            layer.close(index);
        });
        return false;
    }

    function del_remote(obj){
        var name = $(obj).attr('data-name');
        layer.confirm('确认移除？', {
            area: ['480px', '190px'],
            shade: layer_shade,
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定','取消'] ,//按钮
            success: function () {
                  $(".layui-layer-content").css('text-align', 'left');
              }
        }, function(){
            layer_loading('正在处理');
            // 确定
            $.ajax({
                type : 'post',
                url : $(obj).attr('data-url'),
                data : {del_id:$(obj).attr('data-id'), _ajax:1},
                dataType : 'json',
                success : function(data){
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 5, title:false});  //alert(data);
                    }
                }
            })
        }, function(index){
            layer.close(index);
        });
        return false;
    }

    function jump() {
        location.reload()
    }

    function remoteInstall(code, min_version) {
        var form2 = $('#form2');
        form2.find('input[name=code]').val(code);
        form2.find('input[name=min_version]').val(min_version);
        var url = "{:url('Weapp/remoteInstall')}";
        form2.attr('action', url);
        layer_loading('远程安装');
        form2.submit();
    }
</script>

{include file="public/footer" /}